import React, { Component } from 'react'
import { UdSelectAjax, http } from '../../../../index'

const Demo = () => {
  return <Selectd />
}

class Selectd extends Component<ISelectdProps, ISelectdState>{
  constructor(props: {}) {
    super(props)
    this.state = {
      value: null
    }
  }
  private change = (e) => {
    this.setState({ value: e })
  }
  render() {
    let style = { width: '500px' }
    return <UdSelectAjax
      placeholder={'请选择...'}
      style={style}
      onChange={this.change}
      value={this.state.value}
      showSearch
      query={() => {
        let data = {
          data: [
            { value: '1', title: '1919' },
            { value: '2', title: '隔壁' },
            { value: '3', title: '快喝' },
            { value: '4', title: '中台' },
            { value: '5', title: '测试1' },
            { value: '6', title: '测试2' }]
        }
        return new Promise((resolve, reject) => {
          setTimeout(() => resolve(data), 1000);
        })
      }} mapping={{ title: 'title', value: 'value' }} />
  }
}


interface ISelectdState {
  value: any
}

interface ISelectdProps {

}



export default Demo
